package jsyf.oa.web.device;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.FastJsonConvert;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.device.CompanyBrandFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by y on 2018/3/12.
 */
@Api(value = "公司品牌接口", description = "公司品牌接口")
@Controller
@RequestMapping("/companyBrand")
public class CompanyBrandController {
    @Resource
    private CompanyBrandFacade companyBrandFacade;

    @ResponseBody
    @RequestMapping(value = "/getCompanyBrandList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "查询公司品牌绑定列表",
            notes = "查询公司品牌绑定列表 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "companyName:'',brandName:'',createTime:'',createUser:'',remark:''", dataType = "String", paramType = "body")
    public void getCompanyBrandList(HttpServletRequest request, HttpServletResponse response,@RequestBody String jsonData ) {
        JSONObject records =this.companyBrandFacade.getCompanyBrandList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(records));
    }

    @ResponseBody
    @RequestMapping(value = "/findCompanyList.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "查询公司列表",
            notes = "查询公司列表 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'userId':''}", dataType = "String", paramType = "body")
    public void findCompanyList(HttpServletRequest request, HttpServletResponse response ,@RequestBody String jsonData) {
        JSONObject records =this.companyBrandFacade.findCompanyList(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }
    @ResponseBody
    @RequestMapping(value = "/findBrandListByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "查询公司下品牌列表*",
            notes = "查询公司下品牌列表* ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'companyId':''}", dataType = "String", paramType = "body")
    public void findBrandListByCompanyId(HttpServletRequest request, HttpServletResponse response , @RequestBody String jsonData) {
        JSONObject records =this.companyBrandFacade.findBrandListByCompanyId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }
    @ResponseBody
    @RequestMapping(value = "/add.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "公司添加品牌",
            notes = "公司添加品牌 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'companyId':'','brandId':''}", dataType = "String", paramType = "body")
    public void add(HttpServletRequest request, HttpServletResponse response , @RequestBody String jsonData) {
        String records =this.companyBrandFacade.add(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records));
    }
    @ResponseBody
    @RequestMapping(value = "/update.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "更改公司品牌",
            notes = "更改公司品牌 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'companyId':'','brandId':''}", dataType = "String", paramType = "body")
    public void update(HttpServletRequest request, HttpServletResponse response , @RequestBody String jsonData) {
        Boolean records =this.companyBrandFacade.update(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records.toString()));
    }
    @ResponseBody
    @RequestMapping(value = "/remove.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "物理删除公司品牌",
            notes = "物理删除公司品牌 ",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{'companyId':'','brandId':''}", dataType = "String", paramType = "body")
    public void remove(HttpServletRequest request, HttpServletResponse response , @RequestBody String jsonData) {
        Boolean records =this.companyBrandFacade.remove(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjRespond(records.toString()));
    }
}
